package com.hsxxherp.simplify.dao.sm.ddl;

import com.baomidou.mybatisplus.extension.ddl.IDdl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Component;

import javax.sql.DataSource;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;

/**
 * Ddl
 * @author 13442
 */
@Component
public class UpdateDdl implements IDdl {


    private static final Log log = LogFactory.getLog(UpdateDdl.class);
    private final DataSource dataSource;

    public UpdateDdl(DataSource dataSource) {
        this.dataSource = dataSource;
    }

    @Override
    public void runScript(Consumer<DataSource> consumer) {
        log.debug("开始自动ddl...");
        consumer.accept(this.dataSource);
    }

    @Override
    public List<String> getSqlFiles() {
        return Arrays.asList(
                "ddl/sm_account.sql",
                "ddl/sm_tenant.sql"
        );
    }
}
